﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace The_Last_Knights.GUI
{
    public class CheckButton: PushButton
    {
        #region Attributes
        protected Texture2D _pushHover;
#endregion

        #region Properties
        public Texture2D PushHover
        {
            get { return _pushHover; }
            set { _pushHover = value; }
        }
#endregion

        public CheckButton(Game game, Text text, string normal, string hover, string push, string ID, Vector2 pos, Vector2 size, Texture2D background, string pushHover) 
            : base(game, text, normal, hover, push, ID, pos, size, background)
        {
            _state.Add(Game.Content.Load<Texture2D>(GameAssertPath.BUTTON_PATH + pushHover));
        }
        
        public override void ChangeHoverState()
        {            
            if (!_isPushing && _state[1] != null)
                _currentState = 1;
            if (_isPushing && _state[3] != null)
                _currentState = 3;
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            if (_isPushing)
            {
                MouseState ms = Mouse.GetState();
                Rectangle boundary = new Rectangle((int)_position.X, (int)_position.Y, (int)_size.X, (int)_size.Y);
                if (boundary.Contains(ms.X, ms.Y))
                    ChangeHoverState();
            }
        }
    }
}
